import { BeforeInsert, BeforeUpdate, Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity()
export class Admin {
    @PrimaryGeneratedColumn({
        comment:'主键id'
    })
    id: number;

    @Column({
        unique: true,
        comment:'账号',
        length:50
    })
    account: string;

    @Column({
        comment:'密码'
    })
    password: string;

    @Column({
        comment:'昵称'
    })
    nickname: string;

    @Column({
        nullable: true,
        comment:'头像'
    })
    headimg: string;

    @Column({
        type: 'bigint',
        update:false,
        comment:'创建时间'
    })
    create_time: number;

    @Column({
        type: 'bigint',
        comment:'修改时间'
    })
    update_time: number;

    @BeforeInsert()
    beforeInsert() {
        this.create_time = new Date().getTime();
        this.update_time = new Date().getTime();
    }

    @BeforeUpdate()
    beforeUpdate() {
        this.update_time = new Date().getTime();
    }
}
